package com.heima.feigns;

import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(
        value = "leadnews-wemedia",
        fallbackFactory = WemediaFeignFallback.class,
        configuration = FeignAutoConfiguration.class)
public interface WemediaFeign {

    @PostMapping("/api/v1/user/save")
    ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    @GetMapping("/api/v1/user/findByName/{name}")
    ResponseResult<WmUser> findByName(@PathVariable("name") String name);

    @GetMapping("/api/v1/news/one/{id}")
    ResponseResult<WmNews> findById(@PathVariable("id") Integer id);

    @PutMapping("/api/v1/news/update")
    ResponseResult updateWmNews(@RequestBody WmNews wmNews);

    @GetMapping("/api/v1/user/findOne/{id}")
    ResponseResult<WmUser> findWmUserById(@PathVariable("id") Integer id);

    /**
     * 查询需要发布的文章id列表
     * @return
     */
    @GetMapping("/api/v1/news/findRelease")
    ResponseResult<List<Integer>> findRelease();
}